< previous page page_59 next page >

Page 59
eliminated these three parameters and the lpReserved parameter, the function is almost identical to the RegEnumKey function, as shown below:
LONG RegEnumValue(
    HKEY hKey,                    // handle of key to query
    DWORD dwIndex,                // index of value to query
    LPTSTR lpValueName,           // address of buffer for value string
    LPDWORD lpcbValueName,        // address for size of value buffer
    LPDWORD lpReserved,           // reserved-Set to NULL
    LPDWORD lpType,               // address of buffer for type code
    LPBYTE lpData,                // address of buffer for value data
    LPDWORD lpcbData              // address for size of data buffer
   );
The Visual Basic declaration is as follows:
Private Declare Function RegEnumValue Lib "advapi32.dll" _
Alias "RegEnumValueA" (ByVal hKey As Long, ByVal dwIndex As Long, _
ByVal lpValueName As String, ByVal lpcbValueName As Long, _
ByVal lpReserved As Long, ByVal lpType As Long, ByVal lpData As Long, _
ByVal lpcbData As Long) As Long
Now let's proceed with the code that does the value enumeration. It is based on and almost identical to the code for enumerating keys. The GetValueInfo function is based on the GetKeyInfo3 function and retrieves the number of subvalues and the length of the buffer needed to hold the value names, as shown below:
' Get the number of values and maximum value length
Private Function GetValueInfo(ByVal hKey As Long, NumberOfValues, _
MaxValueNameLength) As Long
   GetValueInfo = RegQueryInfoKeyV3(hKey, vbNullString, 0, 0, 0, 0, _
   0, VarPtr(NumberOfValues), VarPtr(MaxValueNameLength), 0, 0, 0)
End Function
The EnumerateValues function is nearly identical to the EnumerateKeys function. The only difference is that instead of building a collection of clsKeyValues objects, it builds a collection of value names, as you can see below:
Private Function EnumerateValues(ByVal hKey As Long) As Collection
   Dim NumberOfSubValues As Long
   Dim MaxSubValueLength As Long
   Dim res As Long
   Dim ValueIndex As Long

 
< previous page page_59 next page >